/*
 * testcase.cpp
 *
 *  Created on: Mar 29, 2015
 *      Author: silivas
 */

#include <gtest/gtest.h>
#include <string>
#include <vector>

#include "gramar.h"
#include "read_grammar.h"
#include "stringop.h"
#include "word.h"

using namespace std;

class TestCase: public testing::Test {
public:
	void SetUp() {

	}
	void TearDown() {

	}

private:
};

TEST_F(TestCase, split_string) {
	string str = "abc egf hijk";
	vector<string> vec = split(str);
	EXPECT_EQ("abc", vec[0]);
	EXPECT_EQ("egf", vec[1]);
	EXPECT_EQ("hijk", vec[2]);
}

TEST_F(TestCase, gramar_add_Category) {
	string tt = "<noun> abc";
	Grammar grammar;
	grammar.add_category(tt);
	EXPECT_EQ("abc", grammar["<noun>"][0][0].toString());
}

TEST_F(TestCase, gramar_add_Category_2) {
	string tt = "<noun> abc efg";
	Grammar grammar;
	grammar.add_category(tt);
	EXPECT_EQ("abc", grammar["<noun>"][0][0].toString());
}

TEST_F(TestCase, creat_grammar_from_rulestxt){
	Grammar ret;
	ret = read_grammar_from_file("rules.txt");
	EXPECT_EQ("cat", ret["<noun>"][0][0].toString());
}

TEST_F(TestCase, creat_grammar_from_rulestxt_2){
	Grammar grammar("rules.txt");
	EXPECT_EQ("cat", grammar["<noun>"][0][0].toString());
}

TEST_F(TestCase, create_sentence){
	Grammar grammar("rules.txt");
	vector<string> str = grammar.gen_sentence();
	vector<string>::iterator it = str.begin();
	for(;it!=str.end();it++)
		cout<<*it<<endl;
}
